# 执行 shell 的 pwd 命令，获得当前目录的绝对路径并保存到变量 TOPSRCDIR，它表示最高层目录
TOPSRCDIR=$(shell pwd)

# 定义该变量表示程序将要被安装的目标位置
DESTDIR=/usr/local/bin/

# 使上述定义的两个变量在子 shell 进程中也有效
export TOPSRCDIR DESTDIR

SUBDIRS = drcomd kmod

# 将 all、clean、install 定义为伪目标，这样可直接执行这些目标中的命令
.PHONY: all clean install
all:	
	@for x in $(SUBDIRS); do\
		(cd $$x && make all) || exit 1;\
	done  

clean: 	
	@for x in $(SUBDIRS); do	(cd $$x && make clean) || exit 1;	done
install:
	@for x in $(SUBDIRS); do	(cd $$x && make install) || exit 1;	done
	@echo
	@echo
	@echo
	@if [ -a /etc/drcom.conf ]; then \
		echo "==============================================" && \
		echo "" && \
		echo "/etc/drcom.conf exists." && \
		echo "" && \
		echo "You May Need to Edit /etc/drcom.conf" && \
		echo "" && \
		echo "=============================================="; \
else \
	install -m 600 drcom.conf /etc/drcom.conf && \
	echo "==============================================" && \
	echo "" && \
	echo "Do Not Forget To Edit /etc/drcom.conf" && \
	echo "" && \
	echo "=============================================="; \
fi
	@echo
